10. Transactions

Transactions

ND004 C01 L02 14 Transactions

Takeaways

  • Databases are interacted using client-server interactions, over a network
  • Postgres uses TCP/IP to be interacted with, which is connection-based
  • We interact with databases like Postgres during sessions
  • Sessions have transactions that commit work to the database
Transactions capture logical bundles of work.

Work is bundled into transactions, so that in case of system failures, data in your database is still kept in a valid state (by rolling back the entire transaction if any part of it fails). To ensure a database is consistent before and after work is done to it, databases uses atomic transactions, and actions like commits and rollbacks to handle failures appropriately. Transactions are, in other words, ACID .


Resource on ACID Properties

See: ACID Properties in DBMS on GeeksforGeeks.org

Transactions

Transactions are:

SOLUTION: atomic units of work for the database to perform as a whole

True/False: a transaction captures a single change done to a database

SOLUTION: False

Transaction statements

Which SQL statements can be added to a transaction?

SOLUTION:
  • UPDATE
  • INSERT
  • DELETE

You can send off the set of changes to the database by ____ the transaction

SOLUTION: commiting

A transaction can be cleared of commands using a ______ .

SOLUTION: rollback